﻿@using MvcApplication2.Models
@model MvcApplication2.Controllers.UserMessageViewModel
@{
    ViewBag.Title = "SendProposal";
}
<h2>
    Send Proposal</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
<form method="post" class="well form-horizontal">
@Html.ValidationSummary(true)
<fieldset>
    <legend>Send exercise proposal [ inserire titolo esercizio e note ] </legend>
    @Html.HiddenFor(model => model.UserMessageId)
    @Html.HiddenFor(model => model.ExerciseId)
    @*@Html.Hidden("userId", (object)ViewBag.userId)*@ @*@Html.Hidden("exerciseId", (object)ViewBag.exerciseId)*@
    <div class="control-group">
        @Html.LabelFor(model => model.Reward, new { @class = "control-label" })
        <div class="controls">
            <div class="input-prepend">
                <span class="add-on">$</span>
                @Html.EditorFor(model => model.Reward, new { @class = "span2" })
                @Html.ValidationMessageFor(model => model.Reward)
            </div>
        </div>
    </div>
    <div class="control-group">
        @Html.LabelFor(model => model.Message, new { @class = "control-label" })
        <div class="controls">
            @Html.TextAreaFor(model => model.Message, new { style = "height:80px ; width:250px" })
            @Html.ValidationMessageFor(model => model.Rating)
            <p class="help-block">
                [Optional]</p>
        </div>
    </div>
    <div class="form-actions">
        <button class="btn btn-primary" type="submit">
            <i class="icon-ok icon-white"></i>Send</button>
        @if (Model.ShowAcceptButton)
        {
            @Html.ActionLink("Accept", "AcceptTestExercise", "User", new { id = Model.UserMessageId }, new { @class = "btn btn-mini btn-success" })
            
            @Html.ActionLink("Rifiuta", "TrashProposal", "User", new { id = Model.UserMessageId }, new { @class = "btn btn-mini btn-warning" })
        }
    </div>
</fieldset>
</form>
<table class="table table-condensed">
    <tr>
        <th>
            From
        </th>
        <th>
            To
        </th>
        <th>
            Date
        </th>
        <th>
            Proposed
        </th>
        <th>
            Message
        </th>
    </tr>
    @foreach (var item in Model.PreviousMessages)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.FormattedFrom)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FormattedTo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FormattedDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Reward)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Message)
            </td>
        </tr>
    }
</table>
<div>
    @Html.ActionLink("Back to List", "Messages", "User", new { @class = "btn btn-inverse" }, null)
</div>
